<extend name="Shops:layout" />
<block name="content">

<script src="__PUBLIC__/plugins/kindeditor/kindeditor.js"></script>
<script src="__PUBLIC__/plugins/kindeditor/lang/zh_CN.js"></script>

<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/webuploader/style.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugins/webuploader/webuploader.css" />
<script type="text/javascript" src="__PUBLIC__/plugins/webuploader/webuploader.js"></script>
<script type="text/javascript" src="__JS__/goodsbatchupload.js"></script>
<!--时间日历插件-->
<script type="text/javascript" src="__PUBLIC__/plugins/jeDate/jedate.js"></script>
<style>
.datainp{ width:150px; }
</style>
<script>
$(function () {
	   $('#tab').TabPanel({tab:0});
	   $.formValidator.initConfig({
		   theme:'Default',mode:'AutoTip',formID:"myform",debug:true,submitOnce:true,
		   onSuccess:function(){
			       editYunGoods('yungoods');
			       return false;
			},onError:function(msg){
		}});
	   
	   $("#goodsName").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:200,onError:"请输入商品标题"});
	   $("#money").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入商品总价"});
	   $("#yunjiage").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入单次价格"});
	   $("#maxqishu").formValidator({onShow:"",onFocus:"",onCorrect:"输入正确"}).inputValidator({min:1,max:50,onError:"请输入最大期数"});
	   
	   $("#goodsCatId3").formValidator({onFocus:"请选择商城分类"}).inputValidator({min:1,onError: "请选择完整商城分类"});
	   $("#shopCatId2").formValidator({onFocus:"请选择本店分类"}).inputValidator({min:1,onError: "请选择完整本店分类"});


    KindEditor.ready(function(K) {
			editor1 = K.create('textarea[name="goodsDesc"]', {
				height:'250px',
				width:"800px",
				allowFileManager : false,
				allowImageUpload : true,
				items:[
				        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
				        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
				        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
				        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','multiimage','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
				        'anchor', 'link', 'unlink', '|', 'about'
				],
				afterBlur: function(){ this.sync(); }
			});
		});
	   KindEditor.ready(function(K) {
			editor1 = K.create('textarea[name="groupDesc"]', {
				height:'250px',
				width:"800px",
				allowFileManager : false,
				allowImageUpload : true,
				items:[
				        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
				        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
				        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
				        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','multiimage','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
				        'anchor', 'link', 'unlink', '|', 'about'
				],
				afterBlur: function(){ this.sync(); }
			});
		});
		
	   <if condition="$object['goodsId'] !=0 ">
	   	getCatListForEdit("goodsCatId2",{$object.goodsCatId1},0,{$object.goodsCatId2});
	   	getCatListForEdit("goodsCatId3",{$object.goodsCatId2},1,{$object.goodsCatId3});
	   	getShopCatListForEdit({$object.shopCatId1},{$object.shopCatId2});
	   </if>
	
});

function imglimouseover(obj){
	if(!$(obj).find('.file-panel').html()){
		$(obj).find('.setdel').addClass('trconb');
		$(obj).find('.setdel').css({"display":""});
	}
}

function imglimouseout(obj){
	
	$(obj).find('.setdel').removeClass('trconb');
	$(obj).find('.setdel').css({"display":"none"});
}

function imglidel(obj){
	if (confirm('是否删除图片?')) {
		$(obj).parent().remove("li");
		return;
	}
}

function imgmouseover(obj){
	$(obj).find('.wst-gallery-goods-del').show();
}
function imgmouseout(obj){
	$(obj).find('.wst-gallery-goods-del').hide();
}
function delImg(obj){
	   $(obj).parent().remove();
}

var filetypes = ["gif","jpg","png","jpeg"];
</script>
       <div class="wst-body"> 
       <div class='wst-page-header'>卖家中心 > <if condition="$object['goodsId'] ==0 ">新增<else/>编辑</if>商品资料</div>
       <div class='wst-page-content'>
       <div id='tab' class="wst-tab-box">
		<ul class="wst-tab-nav">
	    	<li>商品信息</li>
	        <li>商品相册</li>
	    </ul>
    	<div class="wst-tab-content" style='width:99%;margin-bottom: 10px;'>

    	<!-- 商品基础信息 -->
    	<div class='wst-tab-item' style="position: relative;">
    		<iframe name="upload" style="display:none"></iframe>
			
			<!--卖家商品添加，图片上传【疑点】-->
			<form id="uploadform_Filedata" autocomplete="off" style="position:absolute;top:155px;left:417px;z-index:10;" enctype="multipart/form-data" method="POST" target="upload" action="{:U('Home/Shops/uploadPic')}" >
				<div style="position:relative;">
				<input id="goodsImg" name="goodsImg" type="text" value="{$object.goodsImg}" readonly style="margin-right:4px;float:left;margin-left:8px;width:140px;"/>
				<div class="div1">
					<div class="div2">浏览</div>
					<input type="file" class="inputstyle" id="Filedata" name="Filedata" onchange="updfile('Filedata');" >
				</div>
				<div style="clear:both;"></div>

				<div >&nbsp;图片大小:350 x 350 (px)(格式为 gif, jpg, jpeg, png)</div>
				<input type="hidden" name="dir" value="goods">
				<input type="hidden" name="width" value="500">
				<input type="hidden" name="folder" value="Filedata">
				<input type="hidden" name="sfilename" value="Filedata">
				<input type="hidden" name="fname" value="goodsImg">
				<input type="hidden" id="s_Filedata" name="s_Filedata" value="">
				
				</div>
			</form>

			<!--表单提交部分-->
	       <form name="myform" method="post" id="myform" autocomplete="off">
	        <input type='hidden' id='id' value='{$object.goodsId}'/>
	      
	        <input type='hidden' id='goodsThumbs' value='{$object.goodsThums}'/>
	        <table class="wst-form" >
	           <tr>
	             <th width='120'></th>
	             <td width='300'></td>
	             <td rowspan='7' valign='top'>
	               <div id="preview_Filedata">
		           <img id='goodsImgPreview' src='<if condition="$object['goodsImg'] =='' ">__ROOT__/{$CONF['goodsImg']}<else/>__ROOT__/{$object['goodsImg']}</if>' height='152'/><br/>
	               </div>
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>商品标题<font color='red'>*</font>：</th>
	             <td><input type='text' id='goodsName' name='title' class="form-control wst-ipt" value='{$object.title}' maxLength='100'/></td>
	           </tr>
	           <tr>
	             <th width='120'>富标题：</th>
	             <td><input type='text' id='title2' name='title2' class="form-control wst-ipt" value='{$object.title2}' maxLength='100'/></td>
	           </tr>
	           <tr>
	             <th width='120'>商品总价<font color='red'>*</font>：</th>
	             <td>
	             <input type='text' id='money' name='money' class="form-control wst-ipt" value='{$object.money}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='10'/>
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>单次价格<font color='red'>*</font>：</th>
	             <td>
	             <input type='text' id='yunjiage' name='yunjiage' class="form-control wst-ipt" value='{$object.yunjiage|default=1}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='10'/>
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>最大期数<font color='red'>*</font>：</th>
	             <td>
	             <input type='text' style="width:60px;" id='maxqishu' name='maxqishu' class="form-control wst-ipt" value='{$object.maxqishu|default=100}' onkeypress="return WST.isNumberdoteKey(event)" onkeyup="javascript:WST.isChinese(this,1)" maxLength='6'/>
	             	<font style="color:#666;">(最大期数为65535)</font>
				 </td>
	           </tr>
	           <tr>
	             <th width='120'>商品SEO关键字：</th>
	             <td colspan='3'>
	             <input type='text' style="width:200px" id='goodsKeywords' name='goodsKeywords' value='{$object.goodsKeywords}' maxlength="100">
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>商品信息：</th>
	             <td colspan='3'>
	             <textarea rows="2" style="width:788px" id='goodsSpec' name='goodsSpec'>{$object.goodsSpec}</textarea>
	             </td>
	           </tr>


	           <tr>
	             <th width='120'>商品属性：</th>
	             <td colspan='3'>
	             <label>
	             <input type='checkbox' id='isRecomm' name='isRecomm' <if condition="$object['isRecomm'] ==1 ">checked</if> value='1'/>推荐
	             </label>
	             <label>
	             <input type='checkbox' id='isBest' name='isBest' <if condition="$object['isBest'] ==1 ">checked</if> value='1'/>精品
	             </label>
	             <label>
	             <input type='checkbox' id='isHot' name='isHot' <if condition="$object['isHot'] ==1 ">checked</if> value='1'/>人气
	             </label>
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>商城分类<font color='red'>*</font>：</th>
	             <td colspan='3'>
	             <select id='goodsCatId1' onchange='javascript:getCatListForEdit("goodsCatId2",this.value,0)'>
	                <option value=''>请选择</option>
	                <volist name="goodsCatsList" id="vo">
	                <option value='{$vo['catId']}' <if condition="$object['goodsCatId1'] == $vo['catId'] ">selected</if>>{$vo['catName']}</option>
	                </volist>
	             </select>
	             <select id='goodsCatId2' onchange='javascript:getCatListForEdit("goodsCatId3",this.value,1);'>
	                <option value=''>请选择</option>
	             </select>
	             <select id='goodsCatId3'>
	                <option value=''>请选择</option>
	             </select>
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>本店分类<font color='red'>*</font>：</th>
	             <td colspan='3'>
	             <select id='shopCatId1' onchange='javascript:getShopCatListForEdit(this.value,"{$object['shopCatId2']}")'>
	                <option value='0'>请选择</option>
	                <volist name="shopCatsList" id="vo">
	                <option value='{$vo['catId']}' <if condition="$object['shopCatId1'] == $vo['catId'] ">selected</if>>{$vo['catName']}</option>
	                </volist>
	             </select>
	             <select id='shopCatId2'>
	                <option value='0'>请选择</option>
	             </select>
	             </td>
	           </tr>
	           <tr>
	             <th width='120' align='right'>品牌：</th>
	             <td>
	             <select id='brandId' dataVal='{$object["brandId"]}'>
	                <option value='0'>请选择</option>
	             </select>
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>商品描述<font color='red'>*</font>：</th>
	             <td colspan='3'>
	             <textarea rows="2" cols="60" id='goodsDesc' name='goodsDesc'>{$object.goodsDesc}</textarea>
	             </td>
	           </tr>
	           <tr>
	             <td colspan='3' style='padding-left:320px;'>
	                 <button class='wst-btn-query' type="submit">保&nbsp;存</button>
	                 <if condition="$umark !='toEdit' ">
	                 <button class='wst-btn-query' type="button" onclick='javascript:location.href="__ROOT__/index.php/Home/Goods/yungoods"'>返&nbsp;回</button>
	                 </if>
	             </td>
	           </tr>
	        </table>
	        </form>
	      </div>
	
	      <!-- 相册 -->
	      <div class='wst-tab-item'>
	      <!-- 
	       <div><input type='text' id='galleryImgUpload'/></div>
	        -->
	       <div id='galleryImgs' class='wst-gallery-imgs'>
                  <div id="tt"></div>
                  <if condition="count($object['gallery']) eq 0" >
                       <div id="wrapper">
                           <div id="container">
            <!--头部，相册选择和格式选择-->
                              <div id="uploader">
                               <div class="queueList">
                                   <div id="dndArea" class="placeholder">
                                      <div id="filePicker"></div>
                                      </div>
                                   <ul class="filelist"></ul>
                               </div>
                             <div class="statusBar" style="display:none">
                               <div class="progress">
                                    <span class="text">0%</span>
                                    <span class="percentage"></span>
                               </div>
                                    <div class="info"></div>
                               <div class="btns">
                                 <div id="filePicker2" class="webuploader-containe webuploader-container"></div><div class="uploadBtn state-finish">开始上传</div>
                               </div>
                            </div>
                         </div>
                      </div>
                   </div>
               <else/>
               	<div id="wrapper">
                       <div id="container">
                          <div id="uploader">
                             <div class="queueList">
                                 <div id="dndArea" class="placeholder element-invisible">
                                    <div id="filePicker" class="webuploader-container"></div>
                                    </div>
                                 <ul class="filelist">
                                 	<volist name="object['gallery']" id="vo" key='i'>
                                 	
                                 		<li style="border: 1px solid rgb(59, 114, 165)" order="100" onmouseover="imglimouseover(this)" onmouseout="imglimouseout(this)">
	                                 		<input type="hidden" class="gallery-img" iv="{$vo.goodsThumbs}" v="{$vo.goodsImg}" />
	                                 		<img width="152" height="152" src="__ROOT__/{$vo.goodsThumbs}"><span class="setdef" style="display:none">默认</span><span class="setdel" onclick="imglidel(this)" style="display:none">删除</span>
                                 		</li>
                                 	
							       	</volist>
                                 </ul>
                            </div>
                            <div class="statusBar" style="">
                               <div class="progress">
                                    <span class="text"></span>
                                    <span class="percentage"></span>
                               </div>
                               <div class="info"></div>
                               <div class="btns">
                                  <div id="filePicker2" class="webuploader-containe webuploader-container"></div>
                                  <div class="uploadBtn state-finish">开始上传</div>
                               </div>
                            </div>
                        </div>
                    </div>
                 </div>
               </if>

	       </div>
	       <div style='clear:both;'></div>
	      </div>

       </div>
       </div>
       
       </div>
       <div style='clear:both;'></div>
       </div>
<script type="text/javascript">
    jeDate({
		dateCell:"#startTime",
		format:"YYYY-MM-DD hh:mm:ss",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19 00:00:00",
		okfun:function(val){}
	});
    jeDate({
		dateCell:"#endTime",
		format:"YYYY-MM-DD hh:mm:ss",
		isinitVal:false,
		isTime:true, //isClear:false,
		minDate:"2014-09-19 00:00:00",
		okfun:function(val){}
	});
</script>
</block>